<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace AlibabaCloud\Client\Traits;

trait MockTrait
{
    private static $mock;
    private static $mockQueue = [];
    public static function mockResponse($status = 200, array $headers = [], $body = NULL)
    {
        if(is_array($body) || is_object($body)) {
            $body = json_encode($body);
        }
        self::$mockQueue[] = new \GuzzleHttp\Psr7\Response($status, $headers, $body);
        self::createHandlerStack();
    }
    private static function createHandlerStack()
    {
        self::$mock = new \GuzzleHttp\Handler\MockHandler(self::$mockQueue);
    }
    public static function mockRequestException($message, \Psr\Http\Message\RequestInterface $request, \Psr\Http\Message\ResponseInterface $response = NULL, \Exception $previous = NULL, array $handlerContext = [])
    {
        self::$mockQueue[] = new \GuzzleHttp\Exception\RequestException($message, $request, $response, $previous, $handlerContext);
        self::createHandlerStack();
    }
    public static function cancelMock()
    {
        self::$mockQueue = [];
        self::$mock = NULL;
    }
    public static function hasMock()
    {
        return (bool) self::$mockQueue;
    }
    public static function getMock()
    {
        return self::$mock;
    }
}

?>